<header class="navbar navbar-expand-lg navbar-light bg-light navbar-static-top sticky-top
{{ if_route('topics.create') || if_route('topics.edit')?'topic-form-header':'' }}">
    <div
        class="{{ if_route('topics.create') || if_route('topics.edit')?'container-fluid col-md-10 offset-md-1':'container' }}">
        <!-- Branding Image -->
        <a class="navbar-brand " href="{{ url('/') }}">
            {{ config('app.name') }}
        </a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
                aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>


        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <!-- Left Side Of Navbar -->
            <ul class="navbar-nav mr-auto">
                <li class="nav-item {{ active_class(if_route('topics.index')) }}">
                    <a class="nav-link" href="{{ route('topics.index') }}">话题</a>
                </li>
                @foreach(get_categories() as $category)
                    <li class="nav-item {{ category_nav_active($category->id) }}">
                        <a class="nav-link"
                           href="{{ route('categories.show', $category->id) }}">{{ $category->name }}</a>
                    </li>
                @endforeach
            </ul>

            <form class="mr-2" method="get" action="{{ route('search') }}">
                <div class="input-group">
                    <input type="search" name="keywords" value="{{ request('keywords') }}"
                           class="form-control" placeholder="请输入搜索关键词">

                    <div class="input-group-append">
                        <button class="btn btn-outline-secondary" type="submit">
                            <i class="fa fa-search"></i>
                        </button>
                    </div>
                </div>

            </form>

            <!-- Right Side Of Navbar -->
            <ul class="navbar-nav navbar-right">
                <!-- Authentication Links -->


                @guest
                    <li class="nav-item"><a class="nav-link" href="{{ route('login') }}">登录</a></li>
                    <li class="nav-item"><a class="nav-link" href="{{ route('register') }}">注册</a></li>
                @else
                    <li class="nav-item">
                        <a class="nav-link mt-1 mr-3 font-weight-bold"
                           href="{{ route('topics.create'). (request('category.id')?'?category_id='.request('category.id'):'') }}">
                            <i class="fa fa-plus"></i>
                        </a>
                    </li>
                    <li class="nav-item notification-badge">
                        <a class="nav-link mr-3 badge badge-pill
                        badge-{{ Auth::user()->notification_count > 0 ? 'hint' : 'secondary' }} text-white"
                           href="{{ route('notifications.index') }}">
                            {{ Auth::user()->notification_count }}
                        </a>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
                           data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <img
                                src="{{ \Illuminate\Support\Facades\Auth::user()->avatar }}"
                                class="img-responsive img-circle" width="30px" height="30px">
                            {{ \Illuminate\Support\Facades\Auth::user()->name }}
                        </a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                            @can('manage_contents')
                                <a class="dropdown-item" href="{{ route('dcat.admin.') }}">
                                    <i class="fas fa-tachometer-alt mr-2"></i>
                                    管理后台
                                </a>
                                <div class="dropdown-divider"></div>
                            @endcan
                            <a class="dropdown-item"
                               href="{{ route('users.show', \Illuminate\Support\Facades\Auth::id()) }}">
                                <i class="far fa-user mr-2"></i>
                                个人中心
                            </a>
                            <a class="dropdown-item"
                               href="{{ route('users.edit',\Illuminate\Support\Facades\Auth::user()) }}">
                                <i class="far fa-edit mr-2"></i>
                                编辑资料
                            </a>

                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" id="logout" href="#">
                                <form action="{{ route('logout') }}" method="POST"
                                      onsubmit="return confirm('您确定要退出吗？');">
                                    {{ csrf_field() }}
                                    <button class="btn btn-block btn-danger"
                                            type="submit" name="button">退出
                                    </button>
                                </form>
                            </a>
                        </div>
                    </li>
                @endguest
            </ul>
        </div>
    </div>
</header>
